#!/bin/bash
#fengk 
#centos 7
#shell start nginx
#version 1.0

WORK_DIR=`dirname "$0"`
PREFIX=${WORK_DIR}
PORT=8081

help(){
    echo "
	--start
	--stop
	--reload
	--help 帮助
	"
}
parse_par(){
    if [ -f "${WORK_DIR}/nginx/sbin/nginx" ]; then
	  chmod +x "${WORK_DIR}/nginx/sbin/nginx"
	else
	  echo "nginx 未找到退出！"
	  exit 1
	fi
    while [ $# -ge 1 ]; do
	    case "$1" in 
		    --start) start;exit;shift 2;;
			--stop) stop;exit;shift 2;;
			--reload) reload;exit; shift 2;;
			--help) help;exit 1;break;;
			*) echo "输入 --help 获取帮助";exit 1;break;;
		esac
	done
}

start(){
    ${WORK_DIR}/nginx/sbin/nginx -p ${PREFIX} -c ${WORK_DIR}/nginx/conf/nginx.conf
}

stop(){
    ${WORK_DIR}/nginx/sbin/nginx -p ${PREFIX} -c ${WORK_DIR}/nginx/conf/nginx.conf -s stop
}

reload(){
    ${WORK_DIR}/nginx/sbin/nginx -p ${PREFIX} -c ${WORK_DIR}/nginx/conf/nginx.conf -s reload
}


main(){
parse_par $*
}


main $*
